﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.OleDb;

namespace SNPAD
{
    public partial class Frm_Rpt_Rework : Form
    {
        public Frm_Rpt_Rework()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {


            string values = @"select z.Fan_Code,a.status_Desc oldTrack_status ,b.status_Desc NewTrack_status ,z.test_time from HV_ZTR z  inner join  HV_Status a 
                              on z.oldTrack_status=a.Track_status inner join HV_Status b on z.NewTrack_status=b.Track_status ";
            values += " where z.test_time between '" + dateTimeInput1.Value.ToString("yyyy-MM-dd") + "' and '" + dateTimeInput2.Value.AddDays(1).ToString("yyyy-MM-dd") + "'";
            if (txtFan_Code.Text.Trim().Length > 0)
            {
                values += " and z.fan_code='" + txtFan_Code.Text.Trim() + "'";
            }
            
            DataTable dt = OleDbHelper3.ExecuteDataTable(values);

            skinDataGridView3.DataSource = dt;

        }

        private void skinButton1_Click(object sender, EventArgs e)
        {
            //Excel.SaveAs(skinDataGridView3);

            Excel.ExportExcel("", skinDataGridView3);
        }
        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void Frm_Rpt_Rework_Load(object sender, EventArgs e)
        {  
            dateTimeInput2.Value = DateTime.Today;
            dateTimeInput1.Value = DateTime.Today;
        }
    }
}
